public class Test1 {
    public static void main(String[] args) {

        for (int i = 0; i <= 999999; i++) {
            int temp = i;
            int sum = 0;
            int count = 0;
            while (temp != 0) {
                count++;
                temp = temp / 10;//判断i是几位数
            }
            temp = i;
            while (temp != 0) {
                sum += Math.pow(temp % 10, count);//Math.pow(a,b)求a的b次方
                temp/=10;
            }
            if (sum==i) {
                System.out.println(sum);
            }
        }
    }
}